<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="/template.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core">
    <ui:define name="title">
        <h:outputText value="#{bundle.ViewUserGroupTitle}"></h:outputText>
    </ui:define>
    <ui:define name="body">
        <h:form id="form" styleClass="form" rendered="#{userController.allowedGroups('1,2')}">
            <p:fieldset legend="User Group View" id="user_create" >
                 <div class="icon_left">
                        <h:commandLink  action="/userGroup/List" styleClass="menu_item" >
                            <h:graphicImage  value="../resources/images/syscon/user_group.png"   />
                            <br/>
                            <h:outputText  value="Group Control"/>
                        </h:commandLink>
                    </div>
                <h:outputText value="#{userGroupController.current.grDesc}" styleClass="engraved"/>
                <br/>
                <h:outputLabel value="ID:"  styleClass="label"/>
                <h:outputLabel value="#{userGroupController.current.grId}" title="#{bundle.ViewUserGroupTitle_grId}" />
                <p:spacer width="10"/>
                <h:outputLabel value="Group Name:" styleClass="label"/>
                <h:outputLabel value="#{userGroupController.current.grDesc}" title="#{bundle.ViewUserGroupTitle_grDesc}" />
                <p:spacer width="10"/>
                <p:separator/>
                <c:if test="#{userController.allowedGroups('1,2')}">
                    <p:commandButton icon="ui-icon-pencil" ajax="false" action="#{userGroupController.prepareEdit}" value="Edit" />
                    <p:spacer width="10"/>
                    <p:commandButton icon="ui-icon-plus" ajax="false" action="#{userGroupController.prepareCreate}" value="New" />
                    <p:spacer width="10"/>
                    <p:commandButton icon="ui-icon-list" ajax="false" action="#{userGroupController.prepareList}" value="Show All" />
                    <p:spacer width="10"/>
                    <p:commandButton icon="ui-icon-close" ajax="false" action="#{userGroupController.destroyAndView}" value="Delete"  />
                    <p:spacer width="10"/>
                </c:if>
                <br/>
                <br/>
                <p:panel id="my_users" styleClass="sub" header="User on this Group"  >
                    <p:fieldset  legend="Available Users" rendered="#{not empty userGroupController.candidateUserList}">
                        <p:panelGrid columns="2" styleClass="remove_border" >
                            <p:selectOneMenu  id="groups" value="#{userGroupController.currentUser}"   requiredMessage="#{bundle.CreateUserHasGroupRequiredMessage_userGroup}">
                                <f:selectItems value="#{userGroupController.candidateUserList}" var="sel_user" itemLabel="#{sel_user.userLogin}" itemValue="#{sel_user}" />
                            </p:selectOneMenu>
                            <p:commandButton id="include" value="Include" actionListener="#{userGroupController.addMeToGroup()}"  update=":form:"  />
                            <p:blockUI block=":form:my_users" trigger="include">
                                <h:outputText value="Please wait, data is being processed..." />  <br/>
                                <p:graphicImage value="/resources/ajaxloader.gif"/>
                            </p:blockUI>
                        </p:panelGrid>
                    </p:fieldset>
                    <br/>
                    <p:dataTable id="user"
                                 value="#{userGroupController.myUserList}"
                                 var="user"
                                 rowKey="#{user}"
                                 >
                        <p:column headerText="User" style="width: 50px">
                            <center>
                                <p:commandLink value="#{user.userLogin}" action="/user/View?faces-redirect=true" styleClass="button-light">
                                    <f:setPropertyActionListener target="#{userController.current}" value="#{user}"/>
                                </p:commandLink>
                            </center>
                        </p:column>
                        <p:column headerText="Remove" style="width: 50px">
                            <center>
                                <p:commandButton id="remove" icon="ui-icon ui-icon-minusthick" title="Remove" immediate="false" actionListener="#{userGroupController.remMeFromGroup(user)}" update=":form:my_users" />
                                <p:blockUI block=":form:my_users" trigger="remove">
                                    <h:outputText value="Please wait, data is being processed..." />  <br/>
                                    <p:graphicImage value="/resources/ajaxloader.gif"/>
                                </p:blockUI>
                            </center>
                        </p:column>
                    </p:dataTable>
                    <br/>

                </p:panel>
                 <br/>
                <br/>
            </p:fieldset>
        </h:form>
    </ui:define>
</ui:composition>


